package cn.afterturn.easypoi.view;

import java.io.File;
import java.io.FileOutputStream;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.HashMap;
import java.util.Map;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.apache.poi.xwpf.usermodel.XWPFDocument;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.RequestMapping;

import cn.afterturn.easypoi.entity.vo.TemplateExcelConstants;
import cn.afterturn.easypoi.entity.vo.TemplateWordConstants;
import cn.afterturn.easypoi.word.WordExportUtil;
import cn.afterturn.easypoi.word.entity.WordImageEntity;

@Controller
@RequestMapping("/wordViewTest")
public class WordExportViewTest {
	@RequestMapping("load")
    public void downloadByWordView(ModelMap modelMap, HttpServletRequest request,
                                      HttpServletResponse response) {
		 Map<String, Object> map = new HashMap<String, Object>();
         map.put("department", "Easypoi");
         map.put("person", "lv");
         SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
         map.put("time", format.format(new Date()));
         WordImageEntity image = new WordImageEntity();
         image.setHeight(200);
         image.setWidth(500);
         image.setUrl("imgs/word/testCode.png");
         image.setType(WordImageEntity.URL);
         map.put("testCode", image);
         
         modelMap.put(TemplateWordConstants.FILE_NAME, "xxxxxxxxxxx");
         //modelMap.put(TemplateExcelConstants.PARAMS, params);
         modelMap.put(TemplateWordConstants.URL, "word/Image.docx");
         modelMap.put(TemplateWordConstants.MAP_DATA, map);
         EasypoiTemplateWordView.render(modelMap, request, response, TemplateWordConstants.EASYPOI_TEMPLATE_WORD_VIEW);
//         PoiBaseView.render(modelMap, request, response,
//        		 TemplateWordConstants.EASYPOI_TEMPLATE_WORD_VIEW);
		
	}
}
